package com.aaa.pro.controller;

import com.aaa.pro.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * fileName:ProductController
 * description:
 * author:MT
 * createTime:2020/1/12 20:33
 * version:1.0.0
 */
@RestController
public class ProductController {
    @Autowired
    private ProductService productService;

    /**
     * 根据条件查询所有商品
     * @param map
     * @return
     */
    @RequestMapping("listProduct")
    public Object productsList(@RequestParam Map map) {
        System.out.println(map);
        return productService.getProducts(map);
    }

    @RequestMapping("listCategory")
    public Object listproductCategory(Long shopId){
        return productService.getProductCategory(shopId);
    }

    @RequestMapping("getProduct")
    public Object getProductById(@RequestParam Map map){
        return productService.getProductById(map);
    }
//    @RequestMapping("listProduct")
//    public Object list(){
//        //return productService.getProductByShopId(1);
//        Map map = new HashMap();
//        map.put("productList",productService.getProducts(map));
//        map.put("categoryList",productService.getCategoryByShopId(1));
//        ResultObject<Map> resultObject =
//                new ResultObject<Map>(ResultStatus.SUCCESS.getCode(),
//                        ResultStatus.SUCCESS.getMsg(),map);
//        return resultObject;
//    }
    @RequestMapping("listIntegralPro")
    public Object listIntegralPro(Long shopId){
        return productService.listIntegralPro(shopId);
    }

    @RequestMapping("getProById")
    public Object getProById(Long id){
        return productService.getProById(id);
    }
}
